Learn R Programming

distr6 (version 1.5.6)

[.ParameterSet: Extract one or more parameters from a ParameterSet

Description

Used to extract one or more parameters from a constructed ParameterSet or ParameterSetCollection.

Usage

# S3 method for ParameterSet
[(ps, ids, prefix = NULL, ...)

Arguments

ps

ParameterSet ParameterSet from which to extract parameters.

ids

(character()) ids of parameters to extract, if id ends with __ then all parameters starting with ids__ are extracted and the prefix is ignored, prefix can be left NULL. See examples.

prefix

(character(1)) An optional prefix to remove from ids after extraction, assumes __ follows the prefix name, i.e. prefix__ids.

...

ANY Ignored, added for consistency.

Examples

Run this code
# NOT RUN {
ps <- VectorDistribution$new(
  distribution = "Binomial",
  params = data.table::data.table(prob = c(0.1, 0.6, 0.2), size = c(2, 4, 6))
)$parameters()

ps["Binom1__prob"] # extracts just Binom1__prob
ps["Binom1__prob", prefix = "Binom1"] # extracts Binom1__prob and removes prefix
ps["Binom1__"] # extracts all Binom1 parameters and removes prefix
# }

Run the code above in your browser using DataLab